package ZuoYe17;

public class Di4 {
    public static void main(String[] args) {
        StringBuilder a=new StringBuilder();
        StringBuffer b=new StringBuffer();
        long start=System.currentTimeMillis();
        for (int i=0;i<100000;i++){
            a.append("c");
        }
        long end=System.currentTimeMillis();
        long time=end-start;
        System.out.println("Builder所用时间"+time+"纳秒");
        long start1=System.currentTimeMillis();
        for (int i=0;i<100000;i++){
            b.append("c");
        }
        long end1=System.currentTimeMillis();
        long time1=end1-start1;
        System.out.println("buffer所用时间"+time1+"纳秒");
        if (time>time1){
            System.out.println("buffer"+"比"+"builder"+"快"+(time-time1)+"纳秒");
        }else {
            System.out.println("builder"+"比"+"buffer"+"快"+(time1-time)+"纳秒");
        }
    }
}
